package com.group9.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.group9.dto.PageInfoResult;
import com.group9.mapper.OrderShowMapper;
import com.group9.dto.OrderShow;
import com.group9.service.OrderShowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderShowServiceImpl implements OrderShowService {

    @Autowired
    OrderShowMapper orderShowMapper;

    @Override
    public List<OrderShow> selectByCustomerIdAndOrderStatus(Integer customerId, Integer orderStatus) {
        List<OrderShow> orderShowList = orderShowMapper.selectByCustomerIdAndOrderStatus(customerId,orderStatus);
        return orderShowList;
    }

    @Override
    public List<OrderShow> selectUnpaidByCustomerIdAndOrderStatus(Integer customerId, Integer orderStatus) {
        List<OrderShow> orderShowUnpaidList = orderShowMapper.selectUnpaidByCustomerIdAndOrderStatus(customerId,orderStatus);
        return orderShowUnpaidList;
    }

    @Override
    public List<OrderShow> selectUndeliverByCustomerIdAndOrderStatus(Integer customerId, Integer orderStatus) {
        List<OrderShow> orderShowUndeliverList = orderShowMapper.selectUndeliverByCustomerIdAndOrderStatus(customerId,orderStatus);
        return orderShowUndeliverList;
    }

    @Override
    public List<OrderShow> selectUnreceiveByCustomerIdAndOrderStatus(Integer customerId, Integer orderStatus) {
        List<OrderShow> orderShowUnreceiveList = orderShowMapper.selectUnreceiveByCustomerIdAndOrderStatus(customerId,orderStatus);
        return orderShowUnreceiveList;
    }

    @Override
    public PageInfoResult<OrderShow> selectAllOrders(PageInfoResult pageParameter) {
        PageHelper.startPage(pageParameter.getCurrPage(),pageParameter.getPageSize());
        List<OrderShow> orderShows = orderShowMapper.selectByCustomerIdAndOrderStatus(null,null);
        PageInfo<OrderShow> pageInfo = new PageInfo<>(orderShows);
        List<OrderShow> list = pageInfo.getList();
        pageParameter.setTotalSize(pageInfo.getTotal());
        pageParameter.setDataList(list);
        return pageParameter;
    }

    @Override
    public int updateOrderStatus(Integer orderId, Integer orderStatus) {
        int rows = orderShowMapper.updateOrderStatus(orderId,orderStatus);
        return rows;
    }

    @Override
    public int orderCount(Integer customerId, Integer orderStatus) {
        int count = orderShowMapper.orderCount(customerId,orderStatus);
        return count;
    }

    @Override
    public List<OrderShow> selectByPage1(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<OrderShow> list = orderShowMapper.selectByCustomerIdAndOrderStatus(1001,1);
        return list;
    }
//
//    @Override
//    public List<OrderShow> selectByPage2(int pageNum, int pageSize) {
//        return null;
//    }
//
//    @Override
//    public List<OrderShow> selectByPage3(int pageNum, int pageSize) {
//        return null;
//    }
//
//    @Override
//    public List<OrderShow> selectByPage4(int pageNum, int pageSize) {
//        return null;
//    }
}
